package com.generator.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @author shkstart
 * @create 2022-09-28 21:59
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").  //表示文件路径，这里的意思是项目包下的所有文件
                addResourceLocations("classpath:/static/"). //表示要开放的资源
                addResourceLocations("classpath:/resources/").
                addResourceLocations("classpath:/templates/").
                addResourceLocations("classpath:/public/").
                addResourceLocations("/img/").
                addResourceLocations("/images/").
                addResourceLocations("/js/").
                addResourceLocations("/css/");
        WebMvcConfigurer.super.addResourceHandlers(registry);


    }

//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        InterceptorRegistration registration = registry.addInterceptor();
//        registration.addPathPatterns("/**"); //所有路径都被拦截
//        registration.excludePathPatterns( //添加不拦截路径
//                "/login",       //登录请求
//                "/**/login.html",       //登录请求
//                "/index",       //登录请求
//                "/**/*.html",   //html静态资源
//                "/**/*.js",     //js静态资源
//                "/**/*.css",    //css静态资源
//                "/**/images",   //css静态资源
//                "/**/img"     //css静态资源
//        );
//
//    }
}
